package models;

import com.fasterxml.jackson.databind.node.ObjectNode;
import play.db.ebean.Model;
import play.libs.Json;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by richard on 04/04/14.
 */
@Entity
public class Service extends Model {

    public ObjectNode toJson(){
        ObjectNode result = Json.newObject();
        result.put("id",id);
        result.put("description",description);
        result.put("tag",tag);
        return result;
    }
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    int id;


    int tag;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getTag() {
        return tag;
    }

    public void setTag(int tag) {
        this.tag = tag;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<EvenementAgenda> getEvenementAgendaList() {
        return evenementAgendaList;
    }

    public void setEvenementAgendaList(List<EvenementAgenda> evenementAgendaList) {
        this.evenementAgendaList = evenementAgendaList;
    }

    String description;

    @OneToMany(mappedBy="service")
    @OrderBy("dateDebut")
    public List<EvenementAgenda> evenementAgendaList = new ArrayList<EvenementAgenda>();



    //ORM
    public static Finder<Long,Service> find = new Finder<Long,Service>(
            Long.class, Service.class
    );

}
